﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Tools;

namespace Pixysoft.Weblications.Sango.Formular
{
    class ServerEnvironmentFormular
    {
        private static DateTime datetime_equipmentupgrade = DateTime.MinValue;

        private static long factor_equipmentupgrade_successrate = -1;

        private static long datetime_materialtrade = -1;

        private static double factor_materialtrade_rate = -1;

        /** 成功率100%的最小等级 */
        private static int default_min_success_rate_level = 10;

        /** 最高成功率 */
        private static int default_max_success_rate = 100;


        /// <summary>
        /// 装备升级成功率
        /// </summary>
        /// <param name="playerLevel"></param>
        /// <returns></returns>
        public static long EquipmentUpgradeSuccessRate(long playerLevel)
        {
            if (playerLevel <= default_min_success_rate_level)
                return default_max_success_rate;

            if (factor_equipmentupgrade_successrate < 0)
            {
                factor_equipmentupgrade_successrate = EquipmentFormular.getSuccessRate();
                datetime_equipmentupgrade = GlobalTimer.Instance.GetGlobalTime();
                return factor_equipmentupgrade_successrate;
            }

            if (EquipmentFormular.isSuccessRateRefresh(datetime_equipmentupgrade))
            {
                factor_equipmentupgrade_successrate = EquipmentFormular.getSuccessRate();
                datetime_equipmentupgrade = GlobalTimer.Instance.GetGlobalTime();
            }

            return factor_equipmentupgrade_successrate;
        }
    }
}
